package com.yl.controller;

import com.yl.dto.InventoryDTO;
import com.yl.entity.Inventory;
import com.yl.query.InventoryQuery;
import com.yl.service.InventoryClientService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author yangl
 */
@RestController
@Api(value = "MongoDB测试接口", tags = "MongoDB测试接口")
public class InventoryController {

    @Resource
    private InventoryClientService inventoryClientService;

    @PostMapping("/save")
    @ApiOperation(value = "新增", notes = "新增")
    public String saveInventory(@RequestBody InventoryDTO inventoryDTO){
        inventoryClientService.saveInventory(inventoryDTO);
        return "success";
    }

    @GetMapping("/select/{status}")
    public List<Inventory> select(@PathVariable("status") String status){
        return inventoryClientService.inventoryList(status);
    }

    @PostMapping("/page")
    public List<Inventory> page(@RequestBody InventoryQuery query){
        return inventoryClientService.inventoryPage(query);
    }
}
